package org.hospital.util;

import com.alibaba.fastjson.JSONObject;

/**
 * Created by pismery on 2017-10-25.
 */
public class StringUtil {
	
    public static String setResult(int code, Object msg, Object result) {
        JSONObject jo = new JSONObject();
        jo.put("code", code);
        jo.put("msg", msg);
        jo.put("result", result);
        return jo.toJSONString();
    }
    
    public static String setResult(int code, Object msg,Object count,Object result) {
    	JSONObject jo = new JSONObject();
    	jo.put("code", code);
    	jo.put("msg", msg);
    	jo.put("count", count);
    	jo.put("result", result);
    	return jo.toJSONString();
    }
    
    public static String rankToString(int rank) {
		switch (rank) {
		case 1:
			return "员工级";
		case 2:
			return "科室级";
		case 3:
			return "门诊级";
		case 4:
			return "总院级";
		case 5:
			return "管理员级";
		default:
			return null;
		}
	}
    
    public static int stringToRank(String rankStr) {
    	switch (rankStr) {
		case "员工级":
			return 1;
		case "科室级":
			return 2;
		case "门诊级":
			return 3;
		case "总院级":
			return 4;
		case "管理员级":
			return 5;
		default:
			return -1;
		}
    }
    
    public static void main(String[] args) {
		System.out.println(stringToRank("员工级"));
		System.out.println(stringToRank("科室级"));
		System.out.println(stringToRank("门诊级"));
		System.out.println(stringToRank("总院级"));
		System.out.println(stringToRank("管理员级"));
		System.out.println(stringToRank("管理员级1"));

		System.out.println(rankToString(1));
		System.out.println(rankToString(2));
		System.out.println(rankToString(3));
		System.out.println(rankToString(4));
		System.out.println(rankToString(5));
	}
}
